#!/bin/bash

echo "Extracting the data from the test speakers for supervised adaptation"
dataDir=data/test
head -n 3 $dataDir/stm > $dataDir/comments.stm
for x in FDHC0 FELC0 FJLM0 FMGD0 FMLD0 FNLP0 FPAS0 FPKT0 MBPM0 MCMJ0 MDAB0 MGRT0 MJDH0 MJLN0 MJMP0 MKLT0 MLLL0 MLNT0 MNJM0 MPAM0 MTAS1 MTLS0 MWBT0 MWEW0; do
  dir=$dataDir/$x
  mkdir -p $dir
  grep ^$x $dataDir/cmvn.scp > $dir/cmvn.scp
  grep ^$x $dataDir/feats.scp > $dir/feats.scp
  grep ^$x $dataDir/spk2utt > $dir/spk2utt
  grep ^$x $dataDir/spk2gender > $dir/spk2gender
  grep ^$x $dataDir/spk2utt > $dir/spk2utt
  grep ^$x $dataDir/utt2spk > $dir/utt2spk
  grep ^$x $dataDir/text > $dir/text
  grep ^$x data/test/stm > $dir/temp.stm
  cat $dataDir/comments.stm $dir/temp.stm > $dir/stm
  rm $dir/temp.stm
  cp $dataDir/glm $dir
  utils/fix_data_dir.sh $dir 
done
rm $dataDir/comments.stm
echo "Data extraction is complete"
